const mongoose = require("mongoose");
// mongoose.connect("mongodb://localhost/test",{useMongoClient:true});
mongoose.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
mongoose.Promise = Promise;

const Article = mongoose.model("Article",{
  loginname:{
    type:String,
    match:[/^[\u4e00-\u9fa5A-Za-z0-9-_]{3,10}$/,"用户名只能使用中英文，数字，下划线，减号，长度在3~10之间。"]
  },
  title:{
    type:String,
    required:[true,"文章标题不得为空。"],
    maxlength:[30,"标题长度在30字以内。"]
  },
  content:{
    type:String,
    required:[true,"文章内容不得为空。"]
  },
  createTime:Date,
  updateTime:Date,
  S_Time:String,        //updateTime格式化为"yyyy-MM-dd hh:mm:ss"形式，以便在各浏览器端统一显示
  accessNum:Number
});

module.exports = Article;
